/*
 * OpenParts
 * A dynamic-loading components framework for GWT
 * Copyright (C) 2011 Christophe Bouthier  [chris{AT}binary-gastronome{DOT}fr]
 *
 * This work is partially based on work I have done at INRIA (http://www.inria.fr) 
 * in the context of the Qualipso European Project (http://qualipso.org/),
 * The work done at INRIA is Copyright (C) 2006-2011 INRIA
 *
 * This work is distributed under the LGPL version 3
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation. See the GNU
 * Lesser General Public License in LGPL.txt for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package fr.openparts.OpenParts.client;

import com.google.gwt.core.client.EntryPoint;

/**
 * Interface to be used by parts in order to bind callbacks into {@link fr.openparts.OpenParts.client.OPBinding}.
 *<p>
 * Add the following lines to the start of the part class:
 * <pre>
 * public interface DummyPartBinder extends OPBinder&lt;DummyPart&gt; {}
 * public static DummyPartBinder binder = GWT.create(DummyPartBinder.class);
 * </pre>
 * Call {@link OPBinder#bindPart(Object) bindPart(this)} when the part is instantiated (typically at the start of the {@link EntryPoint#onModuleLoad()} of the part), and 
 * {@link OPBinder#notifyLoadingCompleted()} at the end of the part instantiation (typically at the end of {@link EntryPoint#onModuleLoad()}).
 * <p>
 * WARNING! Due to a <a href="http://code.google.com/p/google-web-toolkit/issues/detail?id=6283">bug in GWT compiler optimization</a>, it may be necessary
 * to drop the <code>static</code> part of the binder, like this:
 * <pre>
 * public DummyPartBinder binder = GWT.create(DummyPartBinder.class);
 * </pre>
 * <p>
 * To specify which methods to bind as callbacks, check the annotations in {@link fr.openparts.OpenParts.client.annotations}.
 * 
 * @author Christophe Bouthier [chris{AT}binary-gastronome{DOT}fr]
 * @creation.date 18 December 2009
 */
public interface OPBinder<C> {

    /**
     * Bind all methods specifically annotated of the given part as callbacks and views factories for this part. Part shouldn't be null.
     * 
     * @param part
     *            the part to bind. Shouldn't be null.
     */
    void bindPart(final C part);
    
    /**
     * Notify the part loader that this part has finished loading and binding itself.
     */
    void notifyLoadingCompleted();

    /**
     * Return the name of the service represented by the part binded by this binder.
     * 
     * @return the name of the service represented by the part binded by this binder.
     */
    String getServiceName();

    /**
     * Return an array containing the name of the resources represented by the part binded by this binder. No guarantee is made on the order.
     * 
     * @return the names of the resources represented by the part binded by this binder, in an array.
     */
    String[] getResourcesNames();
}
